package com.zznj.xzjc.adapter.index;

import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zznj.xzjc.R;
import com.zznj.xzjc.bean.index.DsrBean;
import com.zznj.xzjc.utils.StringUtils;

import java.util.List;

/**
 * 描述：添加类的描述
 *
 * @author wx5e48d604c2885118
 * @time 2020/4/7
 */
public class DsrAdapter extends BaseQuickAdapter<DsrBean, BaseViewHolder> {

    public DsrAdapter(int layoutResId, @Nullable List<DsrBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, DsrBean item) {
        helper.setText(R.id.titleLabel,"当事人情况"+(helper.getLayoutPosition()+1));
        helper.addOnClickListener(R.id.delBtn);
        helper.addOnClickListener(R.id.dsrlxTv);
        helper.addOnClickListener(R.id.sexTv);
        helper.addOnClickListener(R.id.guojiTv);

        EditText dwmcTv = helper.getView(R.id.dwmcTv);
        TextView dsrlxTv = helper.getView(R.id.dsrlxTv);
        TextView sexTv = helper.getView(R.id.sexTv);
        EditText sfzhmTv = helper.getView(R.id.sfzhmTv);
        EditText gzdwjdzTv = helper.getView(R.id.gzdwjdzTv);
        EditText fddbrxmTv = helper.getView(R.id.fddbrxmTv);
        EditText fddbrzwTv = helper.getView(R.id.fddbrzwTv);
        EditText lxdzTv = helper.getView(R.id.lxdzTv);
        EditText yzbmTv = helper.getView(R.id.yzbmTv);
        EditText lxfsTv = helper.getView(R.id.lxfsTv);
        EditText wtdlrTv = helper.getView(R.id.wtdlrTv);
        EditText wtdlrlxfsTv = helper.getView(R.id.wtdlrlxfsTv);
        TextView guojiTv = helper.getView(R.id.guojiTv);
        TextView beizhuTv = helper.getView(R.id.beizhuTv);

        dwmcTv.setText(StringUtils.toString(item.getPartyName()));
        dsrlxTv.setText(StringUtils.toString(item.getPartyTypeName()));
        sexTv.setText(StringUtils.toString(item.getSexName()));
        sfzhmTv.setText(StringUtils.toString(item.getCardNo()));
        gzdwjdzTv.setText(StringUtils.toString(item.getUnitAddress()));
        fddbrxmTv.setText(StringUtils.toString(item.getLegalPersonName()));
        fddbrzwTv.setText(StringUtils.toString(item.getLegalPersonDuty()));
        lxdzTv.setText(StringUtils.toString(item.getAddress()));
        yzbmTv.setText(StringUtils.toString(item.getPostalCode()));
        lxfsTv.setText(StringUtils.toString(item.getPhoneNumber()));
        wtdlrTv.setText(StringUtils.toString(item.getAgentPersonName()));
        wtdlrlxfsTv.setText(StringUtils.toString(item.getAgentPhoneNumber()));
        guojiTv.setText(StringUtils.toString(item.getNationName()));
        beizhuTv.setText(StringUtils.toString(item.getRemark()));

        dwmcTv.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                item.setPartyName(s.toString());
            }
            @Override
            public void afterTextChanged(Editable s) {
            }
        });

        sfzhmTv.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {}
            @Override
            public void afterTextChanged(Editable s) {
                item.setCardNo(s.toString());
            }
        });
        gzdwjdzTv.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {}
            @Override
            public void afterTextChanged(Editable s) {
                item.setUnitAddress(s.toString());
            }
        });
        fddbrxmTv.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {}
            @Override
            public void afterTextChanged(Editable s) {
                item.setLegalPersonName(s.toString());
            }
        });
        fddbrzwTv.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {}
            @Override
            public void afterTextChanged(Editable s) {
                item.setLegalPersonDuty(s.toString());
            }
        });
        lxdzTv.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {}
            @Override
            public void afterTextChanged(Editable s) {
                item.setAddress(s.toString());
            }
        });
        yzbmTv.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {}
            @Override
            public void afterTextChanged(Editable s) {
                item.setPostalCode(s.toString());
            }
        });
        lxfsTv.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {}
            @Override
            public void afterTextChanged(Editable s) {
                item.setPhoneNumber(s.toString());
            }
        });
        wtdlrTv.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {}
            @Override
            public void afterTextChanged(Editable s) {
                item.setAgentPersonName(s.toString());
            }
        });
        wtdlrlxfsTv.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {}
            @Override
            public void afterTextChanged(Editable s) {
                item.setAgentPhoneNumber(s.toString());
            }
        });
        beizhuTv.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {}
            @Override
            public void afterTextChanged(Editable s) {
                item.setRemark(s.toString());
            }
        });
    }
}
